package com.bluesky.android.webservice;

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class MangaCollection {
	private int currentPage;
    private int totalPage;
    private List<MangaStory> mangaList;
    public MangaCollection(){
    	this.currentPage = 0;
    	this.totalPage = 0;
    	this.mangaList = new ArrayList<MangaStory>();
    }
    public static MangaCollection GetMangaCollectionFromSoapObject(SoapObject soapObject){
    	MangaCollection mangaCollection = new MangaCollection();
    	mangaCollection.setCurrentPage(Integer.parseInt(soapObject.getProperty("CurrentPage").toString() ) );
    	mangaCollection.setTotalPage(Integer.parseInt(soapObject.getProperty("TotalPage").toString() ) );
    	PropertyInfo mangaStoryListInfo = new PropertyInfo();
		soapObject.getPropertyInfo(1, mangaStoryListInfo);
		SoapObject mangaCollectionSoapObject =(SoapObject) mangaStoryListInfo.getValue();
		int countOfMangaInList = mangaCollectionSoapObject.getPropertyCount();
		for(int i=0; i< countOfMangaInList; i++)
		{
			PropertyInfo mangaStoryInfo = new PropertyInfo();
			mangaCollectionSoapObject.getPropertyInfo(i, mangaStoryInfo);
			SoapObject mangaStoryObject = (SoapObject) mangaStoryInfo.getValue();
			MangaStory mangaStory = MangaStory.GetMangaStoryFromSoapObject(mangaStoryObject);
			mangaCollection.getMangaList().add(mangaStory);
		}
    	return mangaCollection;
    }
    public MangaCollection(int currentPage, int totalPage, List<MangaStory> mangaList){
    	this.currentPage = currentPage;
    	this.totalPage = totalPage;
    	this.mangaList = mangaList;
    }
	public void setMangaList(List<MangaStory> mangaList) {
		this.mangaList = mangaList;
	}
	public List<MangaStory> getMangaList() {
		return mangaList;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getCurrentPage() {
		return currentPage;
	}
}
